
var vm =  new Vue({
    el : "#app",
    data : {
    cont_show_:true,
    id:'',
    start:'',//入住时间
    end:'',//离店时间
    day_time:'',//入住天数
    userPhone:'15858585558',
    token:'',//id
    hotelId:'',
    info:'',//酒店介绍
    yesterday:'',//昨天日期
    address:'',//位置
    imgServerUrl:'',//图片地址前缀
    hotelImg1Url:'',//图片地址1
    hotelImg2Url:'',//图片地址2
    hotelImg3Url:'',//图片地址3
    hotelName:'',//酒店名字
    city_aggre:{},//房间集合
    unitPrice:'',//单价。。接口获取的or上个页面传来的
      },
    created:function(){
        this.getDate();//获取时间
        this.token = _lSGet('token');//获取公用token
        this.hotelId = _lSGet('hotelId');
        this.address = _lSGet('address');//获取上个页面传入的位置
        this.hotelName = _lSGet('hotelName');//获取上个页面传入的酒店名
        this.userPhone = _lSGet('reservePhone');//获取上个页面传入的电话
        this.info = _lSGet('info');//获取上个页面传入的酒店信息
        this.hotelImg1Url = _lSGet('hotelImg1Url');//获取图片1
        this.hotelImg2Url = _lSGet('hotelImg2Url');//获取图片2
        this.hotelImg3Url = _lSGet('hotelImg3Url');//获取图片3

        if( _lSGet('urls')){
            var urls =JSON.parse( _lSGet('urls'));
            this.imgServerUrl=urls.imgServerUrl+'/';
        }else{
            this.imgServerUrl=imgViewUrl;//配置里的固定路径
        }
        this.getData();//请求列表
        //alert(this.address);
        //alert(this.token);
        //alert(this.hotelId);
        //var that=this;
        //var params = {};
        //params.hotelId = this.hotelId;
        //params.page=1;
        //params.pageSize=10;
        //params.checkinTime=null;//入住时间
        //params.checkoutTime=null;//离店时间
        //params.checkinType=2;//短租固定2
        //params.pageSize=10;
        //params.token=this.token;
        //sendRequest('/roomTypeStatus/getReserveNum', params, function(res) {
        //    //that.go_login_home(res);
        //    //res = res.data;
        //    goLogin(res);//公用回家
        //    console.log('okla')
        //    console.log(res)
        //    if(res.status == '1') {
        //    that.city_aggre=res.rows;
        //    console.log(that.city_aggre);
        //    //     for(var i=0;i<res.rows.length;i++){
        //    //        that.city_aggre.push(res.rows[i].provinceId);
        //    //       //console.log(res.rows[i].provinceId)
        //    //      //console.log(this.city_aggre)
        //    //     }
        //    //  // alert('ok')
        //
        //    // } else {
        //    //   //Toast(res.message);
        //     }
        //});

  },
  mounted:function(){
    var that=this;
      setTimeout(function(){//下面解决点击白块空白
         // $('.ta_calendar').css('background-color','red');
          $('.ta_calendar').css({
              'margin-top':'-35px',
            // 'background-color' :'red'
          })   ;
          $('.ta_calendar_footer').css({
              'margin-bottom':'10rem',
            // 'background-color' :'red'
          });
          //$(".cont-list:last").css(' border-bottom','0px');
          $(".cont-list:last").css('border-bottom','0px solid red');
          if(that.city_aggre.length==0){
              $('.check-time').css('border-bottom','0px solid red');
          }
          $('.frm_msg').css('display','none');//把日历input框隐藏
      },200)
     this.dateRange1 = new pickerDateRange('date1', {
        aRecent90Days : 'aRecent90Days', //最近90天
        //isTodayValid : true,
        isTodayValid : true,
        startDate:that.start,
        //startDate: that.start,
        endDate: that.end,//这里改以前的时间会悬赏
        magicSelect : false,
        needCompare : false,
        defaultText : '离开',
        autoSubmit : false,
        //stopToday : false,
        //autoSubmit : true,
        inputTrigger : 'input_trigger1',
        theme : 'ta',
        success : function(obj) {//点击确认按钮
            that.cont_show_=true;//让页面显示
            //alert('ok')
            console.log(obj)
            that.end=obj.endDate;
            that.start=obj.startDate;
            //alert(obj.startDate)
            //router.replace('/index-cont?id='+this.id+'&start='+start+'&end='+end+'')
        }
    });
    var that=this;
     $(".frm_btn input:eq(1)").click(function(){//点击取消按钮
        that.cont_show_=true;//点取消让页面再显示
      })

  },
     methods:{
       go_time:function(){
       var that=this;
       setTimeout(function(){
       $('#date1').click();
         that.cont_show_=false;
         //$('.cf').css('display','none')
        },10)

    },
         getData:function(){

             var that=this;
             var params = {};
             params.hotelId = this.hotelId;
             params.page=1;
             params.pageSize=10;
             params.checkinTime=this.start;//入住时间
             params.checkoutTime=this.end;//离店时间
             params.checkinType=2;//短租固定2
             params.pageSize=10;
             params.token=this.token;
             sendRequest('/roomTypeStatus/getReserveNum', params, function(res) {
                 //that.go_login_home(res);
                 //res = res.data;
                 //goLogin(res);//公用回家
                 console.log('okla')
                 console.log(res)
                 if(res.status == '1') {
                     that.city_aggre=res.rows;
                     console.log(that.city_aggre);
                     //     for(var i=0;i<res.rows.length;i++){
                     //        that.city_aggre.push(res.rows[i].provinceId);
                     //       //console.log(res.rows[i].provinceId)
                     //      //console.log(this.city_aggre)
                     //     }
                     //  // alert('ok')

                     // } else {
                     //   //Toast(res.message);
                 }
             });
         },
    //go_login_home:function(res){//统一验证状态
    //console.log('+++++++')
    //console.log(res);
    //if(res.returnCode=="MEM-1001"){
    ////alert('这里跳转到登录页')
    //window.location.href=backUrl;
    //  }
    //},

  //FormatDate (strTime) {
  //  var date = new Date(strTime);
  //  return date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate();
  //    },
    FormatDate :function (strTime){
        var date = new Date(strTime);
        var y = 1900+date.getYear();
        var m = "0"+(date.getMonth()+1);
        var d = "0"+date.getDate();
        return y+"-"+m.substring(m.length-2,m.length)+"-"+d.substring(d.length-2,d.length);

    },
  //getDate(){
  //var date = new Date();
  ////var currentTime = date.Format("yyyy-MM-dd hh:mm:ss");
  //console.log(date)
  //var pp=this.FormatDate(date)
  //// alert(pp)
  //this.start=this.FormatDate(date);
  //this.end=this.FormatDate(date);
  //
  //},

  getDate:function (){
        var date = new Date();
        var dateyes = new Date(new Date()-24*60*60*1000);
        var tomorrow = new Date(new Date()*1+24*60*60*1000);
        //var currentTime = date.Format("yyyy-MM-dd hh:mm:ss");
        console.log(date);
        var pp=this.FormatDate(date);
        // alert(pp)
        this.start=this.FormatDate(date);
        this.yesterday=this.FormatDate(dateyes);
        //this.end=this.FormatDate(tomorrow);
        this.end=this.FormatDate(tomorrow);

},
  go_map:function(){
        //router.push('/map')
        window.location.href=indexUrl+'/app/map.html?_t=' + Math.random();
  },
  call_phone:function(){
     window.location.href='tel:'+this.userPhone+'';
   },
   errImg:function(e){//图片错误处理
             //var img= e.target;
             $( e.target).attr("src","./assets/img/imgeee.png");
   },

  go_order:function(k,v,d,e,f,g){
      if(this.hotelName!='测试店'){
        tips('只开放测试店');
          return;
      }
        //alert(d);
       _lSSaveOrUpdate( 'price',k);
       _lSSaveOrUpdate( 'price2',v);
       _lSSaveOrUpdate( 'breakCount',d);//早餐券
       _lSSaveOrUpdate( 'roomTypeId',e);
        // _lSSaveOrUpdate( 'hotelId',j);//为啥主食呢 这里的hotelId是上个页面的id 不是此处的null
       _lSSaveOrUpdate( 'roomTypeName',f);//房型名
       _lSSaveOrUpdate( 'reserveCount',g);//可订数
       _lSSaveOrUpdate( 'start',this.start); //保存进店时间
       _lSSaveOrUpdate( 'end',this.end); //保存离店时间
       _lSSaveOrUpdate( 'day_time', this.day_time); //保存入住天数
       _lSSaveOrUpdate( 'unitPrice', this.unitPrice); //保存房间单价

      var that=this;
      var params = {};
      params.token=this.token;
      sendRequest('/check/login', params, function(res) {
          //that.go_login_home(res);
          //res = res.data;
          if(res.returnCode=="yuju-1022"){
              var   opId = _lSGet('opId');
              if(!opId){
                  layer.open({
                      content: '用户未登录，请点击确认登录!'
                      ,btn: ['确认', '取消']
                      ,yes: function(index){
                          _lSSaveOrUpdate( 'forwordPage','/app/order.html');
                          goLogin(res);//公用回家
                      }
                  })
              }else{
                  _lSSaveOrUpdate( 'forwordPage','/app/order.html');
                  goLogin(res);//公用回家
              }

          }else{
              window.location.href=indexUrl+'/app/order.html?_t=' + Math.random();
          }

      });
      //
        //router.push('/order');

  } ,
  sendRequest:function(urls,params,successFunc){//封装请求方法
    $.ajax({
         type: "post",
         url:url+urls,
         data:params,
         cache:false,
         //contentType:'application/x-www-form-urlencoded',
         async:true,
          //dataType: 'json',
         success: successFunc
     });
    },
  },
  computed: {
    days:function(){//计算天数
        var start_d= Date.parse(this.start.replace(/-/g,"/"));
        var end_d= Date.parse(this.end.replace(/-/g,"/"));
        var dayCount = Math.floor((Math.abs(start_d - end_d))/1000/60/60/24);
        this.day_time=dayCount;
        //alert(dayCount);
        return dayCount;
    }
 },
   watch:{
        start:function(){//时间改变触发请求
            this.getData();
        },
        end:function(){//同上
            this.getData();
        }
    },

  components:{


  }


});